<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数组filter方法</title>
</head>

<body>
  <script>
    // filter方法和map方法类似,有返回值,返回符合条件的新数组
    const arr = [10, 20, 30]
    let newArr = arr.filter(function (item, index) {
      console.log(item, index);
      return item >= 20
    })
    console.log(newArr);
  </script>
</body>

</html>